﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace MixingStation
{
    public partial class CarCodeModifyForm : Form
    {
        private string m_CarCode = "";
        public string CarCode
        {
            get
            {
                return m_CarCode;
            }
            set
            {
                m_CarCode = value;
            }
        }

        public CarCodeModifyForm()
        {
            InitializeComponent();
        }

        private void CarCodeModifyForm_Load(object sender, EventArgs e)
        {
            txtOriginalCarCode.Text = m_CarCode;
            txtNewCarCode.Focus();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNewCarCode.Text.Trim()))
            {
                MessageBox.Show("修改车牌号不能为空");
                txtNewCarCode.Focus();
                return;
            }
            if (txtOriginalCarCode.Text.Trim() == txtNewCarCode.Text.Trim())
            {
                MessageBox.Show("车牌号与原车牌号一致");
                txtNewCarCode.Focus();
                return;
            }
            string carNumber = txtNewCarCode.Text.Trim();
            if (!CommonHelper.InValidData(carNumber))
            {
                MessageBox.Show("请输入正确格式车牌号");
                txtNewCarCode.Focus();
                return;
            }
            if (carNumber.Length == 8)
                carNumber += "..";
            else if (carNumber.Length == 9)
                carNumber += ".";
            m_CarCode = carNumber;
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
